package com.poly.system.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;
import java.util.concurrent.atomic.AtomicReference;

/**
 * redis通知主题
 *
 * @author xubing
 * @updateTime 2023/9/14 11:20
 */
@Getter
@RequiredArgsConstructor
public enum RedisTopicEnum {
    ZZ_TOPIC("ZZ_TOPIC", "水位变动通知主题"),
    QQ_TOPIC("QQ_TOPIC", "流量变动通知主题"),
    SQ_TOPIC("SQ_TOPIC", "小时流量变动通知主题"),
    FQ_TOPIC("FQ_TOPIC", "累计水量变动通知主题"),
    NOTICE_TOPIC("NOTICE_TOPIC", "闸门变动通知主题"),
    ALARM_TOPIC("ALARM_TOPIC", "新报警通知主题"),
    WEATHER_TOPIC("WEATHER_TOPIC", "天气通知主题");
    //主题
    private final String topic;

    //主题描述
    private final String desc;

    /**
     * 通过值获取名称
     *
     * @param value
     * @return
     */
    public static String getTopic(String value) {
        AtomicReference<String> nameStr = new AtomicReference<>();
        Arrays.asList(values()).forEach(p -> {
            if (p.getTopic().equals(value)) {
                nameStr.set(p.getDesc());
            }
        });
        return nameStr.get();
    }
}
